package tests;

import java.util.ArrayList;

import org.junit.Test;

import utils.AmbigousPath;
import utils.Node;
import utils.Path;
import utils.TreeUtils;

public class PathsTest {

	@Test
	public final void testGetPaths() {
		TreeConstants.init();

		// System.out.println("Configuration:");
		// TreeUtils.printTree(TreeConstants.configuration, "");

		// System.out.println("Rule:");
		// TreeUtils.printTree(TreeConstants.rule1, "");

		Node cfg = TreeConstants.configuration;
		Node rule = TreeConstants.rule1;

		ArrayList<Node> leaves = TreeUtils.getLeaves(rule);

		System.out.println("Leaves:");
		for (Node n : leaves)
			System.out.println(n);

		ArrayList<Path> paths = TreeUtils.getPaths(cfg, leaves);
		System.out.println("Paths:");
		for (Path p : paths)
			System.out.println(p);

		ArrayList<Node> in = TreeUtils.getIntermediateNodes(rule);

		System.out.println("Inode:");
		for (Node n : in)
			System.out.println(n);

		ArrayList<Path> ipaths = TreeUtils.getPaths(cfg, in);
		System.out.println("Paths I:");
		for (Path p : ipaths)
			System.out.println(p);

		paths = TreeUtils.getPathContext(paths, ipaths, rule.label);
		System.out.println("Latest:");
		for (Path p : paths)
			System.out.println(p);

		ArrayList<AmbigousPath> pth = TreeUtils.detectAmbiguity(paths);
		if (pth != null) {
			System.out.println("Ambiguities:");
			for (AmbigousPath p : pth)
				System.out.println(p);
		}
	}

}
